.class public Llt/noframe/gpsfarmguide/clicks_chain/AreaSelectHandler;
.super Llt/noframe/gpsfarmguide/clicks_chain/ClickHandler;
.source "AreaSelectHandler.java"


# direct methods
.method public constructor <init>()V
    .locals 0

    .line 19
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/clicks_chain/ClickHandler;-><init>()V

    return-void
.end method


# virtual methods
.method public handleRequest(Lcom/google/android/gms/maps/model/LatLng;)Llt/noframe/gpsfarmguide/models/MeasuringModel;
    .locals 4

    .line 24
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getAreas()Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :cond_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    const/4 v2, 0x0

    if-eqz v1, :cond_2

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Llt/noframe/gpsfarmguide/models/MeasuringModel;

    .line 25
    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v3

    invoke-static {p1, v3}, Llt/noframe/gpsfarmguide/utils/Mathematics;->isInPolygon(Lcom/google/android/gms/maps/model/LatLng;Ljava/util/List;)Z

    move-result v3

    if-eqz v3, :cond_0

    .line 27
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p1

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object p1

    if-eqz p1, :cond_1

    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p1

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object p1

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getId()I

    move-result p1

    invoke-virtual {v1}, Llt/noframe/gpsfarmguide/models/MeasuringModel;->getId()I

    move-result v0

    if-ne p1, v0, :cond_1

    return-object v1

    .line 31
    :cond_1
    new-instance p1, Llt/noframe/gpsfarmguide/clicks_chain/DeselectHandler;

    invoke-direct {p1}, Llt/noframe/gpsfarmguide/clicks_chain/DeselectHandler;-><init>()V

    invoke-virtual {p1, v2}, Llt/noframe/gpsfarmguide/clicks_chain/DeselectHandler;->handleRequest(Lcom/google/android/gms/maps/model/LatLng;)Llt/noframe/gpsfarmguide/models/MeasuringModel;

    .line 32
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p1

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/Data;->getMapStatesController()Llt/noframe/gpsfarmguide/states/map_states/MapStatesController;

    move-result-object p1

    new-instance v0, Llt/noframe/gpsfarmguide/states/map_states/MeasureSelectedState;

    invoke-direct {v0, v1}, Llt/noframe/gpsfarmguide/states/map_states/MeasureSelectedState;-><init>(Llt/noframe/gpsfarmguide/models/MeasuringModel;)V

    invoke-virtual {p1, v0}, Llt/noframe/gpsfarmguide/states/map_states/MapStatesController;->setCurrentState(Llt/noframe/gpsfarmguide/states/map_states/MapState;)V

    .line 33
    invoke-static {}, Llt/noframe/gpsfarmguide/App;->getContext()Landroid/content/Context;

    move-result-object p1

    const-string v0, "saved_measure_selected"

    invoke-static {v0, p1}, Llt/noframe/gpsfarmguide/App;->stateChanged(Ljava/lang/String;Landroid/content/Context;)V

    .line 34
    new-instance p1, Llt/noframe/gpsfarmguide/analytics/FireAnalytics;

    invoke-static {}, Llt/noframe/gpsfarmguide/App;->getContext()Landroid/content/Context;

    move-result-object v0

    invoke-direct {p1, v0}, Llt/noframe/gpsfarmguide/analytics/FireAnalytics;-><init>(Landroid/content/Context;)V

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/analytics/FireAnalytics;->sendMapFieldSelect()V

    return-object v1

    .line 44
    :cond_2
    iget-object v0, p0, Llt/noframe/gpsfarmguide/clicks_chain/ClickHandler;->nextHandler:Llt/noframe/gpsfarmguide/clicks_chain/ClickHandler;

    if-eqz v0, :cond_3

    .line 45
    invoke-virtual {v0, p1}, Llt/noframe/gpsfarmguide/clicks_chain/ClickHandler;->handleRequest(Lcom/google/android/gms/maps/model/LatLng;)Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object p1

    return-object p1

    :cond_3
    return-object v2
.end method
